package com.itboye.sunsun.adapter;

import java.util.List;

import com.itboye.sunsun.R;
import com.itboye.sunsun.address.ForumPostModel;
import com.itboye.sunsun.address.MyPostModel;
import com.itboye.sunsun.beans.GoodBean;
import com.itboye.sunsun.beans.OrderBean;
import com.itboye.sunsun.utils.XImageLoader;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class MyPostAdaper extends BaseAdapter {
	/***
	 * 2016-03-04 论坛帖子
	 * 
	 * @author
	 */

	private Context context;
	private List<MyPostModel> list;

	public MyPostAdaper(Context context, List<MyPostModel> list2) {
		this.context = context;
		this.list = list2;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list==null?0:list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public int getItemViewType(int position) {
		// TODO Auto-generated method stub
		return position;
	}
//设置我的帖子下拉刷新返回的值
//	public int getViewTypeCount(int position) {
//		// TODO Auto-generated method stub
//		return position;
//	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		HandView mView;
		
		// /当控件为空时加载布局文件中item
		if (convertView == null) {
			mView = new HandView();
			// /////////得到Mypostitem界面
			convertView = LayoutInflater.from(context).inflate(
					R.layout.forum_post_item_andpost, null);
			mView.postname=(TextView) convertView.findViewById(R.id.post_name);
			mView.posttime=(TextView) convertView.findViewById(R.id.post_time);
			mView.postcontent=(TextView) convertView.findViewById(R.id.post_content);
//			mView.imgleft=(ImageView) convertView.findViewById(R.id.img_post_leit);
//			mView.imgcentent=(ImageView) convertView.findViewById(R.id.img_post_centet);
//			mView.imgright=(ImageView) convertView.findViewById(R.id.img_post_gheit);
			convertView.setTag(mView);
		} else {
			// *** **/////
			mView = (HandView) convertView.getTag();
		}
		mView.postname.setText(list.get(position).getAuthor());
		mView.posttime.setText(list.get(position).getUseip());
		mView.postcontent.setText(list.get(position).getMessage());
//		XImageLoader.load(list.get(position).getUrl(),mView.imgleft);
//		XImageLoader.load(list.get(position).getUrl(),mView.imgcentent);
//		XImageLoader.load(list.get(position).getUrl(),mView.imgright);
		return convertView;
	}

	class HandView {
		private ImageView imghed;// 用户头像
		private TextView postname;// 名字
		private TextView posttime;// 时间
		private TextView postcontent;// 内容
//		private ImageView imgleft;// 图片
		private ImageView imgcentent;//
		private ImageView imgright;
		private ImageView zan;// 赞
		private ImageView ping;// 评论
		private TextView txt_zan;
		private TextView txt_pinmg;
	}

}
